package tables;

public class Artist extends AbstractEntity{
	
	static int virtualId = -1;
	
	public Artist(int id, String name) {
		super(id, name);
	}
	
	public void addArtist(Artist artist) {
		if(this.name.length() == 0){
			this.setName(artist.getName());
		}else{
			this.setName(this.getName() + " & " + artist.getName());
		}
	}
	
	//********* virtualId tools *********\\
	/**
	 * if table is empty, then virtual id is set to 0,
	 * so when we call to addVirtualId we get id 1 - the first row;
	 * @param realVirtualId
	 */
	public static void initalizeVirtualId(int realVirtualId){
		virtualId = realVirtualId;
	}
	
	public static int getVirtualId() {
		return virtualId;
	}
	
	public static void addVirtualId(){
		virtualId++;
	}
	
	public static boolean isInitalized(){
		if(virtualId < 0){
			return false;
		}else{
			return true;
		}
	}
	
	public int fixId(){
		if(!isValidId()){
			addVirtualId();
			setId(getVirtualId());
		}
		return getId();
	}
	
	
	
	
}


